<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LINE 1 &quot;libraries\\Win32\\Graphics\\Win32\\Window\\HotKey.hsc&quot; #-}</span><span>
</span><span id="line-1"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-comment">{- |
   Module      :  Graphics.Win32.Window.HotKey
   Copyright   :  2013 shelarcy
   License     :  BSD-style

   Maintainer  :  shelarcy@gmail.com
   Stability   :  Provisional
   Portability :  Non-portable (Win32 API)

   An FFI binding to the hot key part of the Win32 API.
-}</span><span>
</span><span id="line-13"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Graphics.Win32.Window.HotKey</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-14"></span><span>
</span><span id="line-15"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Bits</span><span>                 </span><span class="hs-special">(</span><span> </span><span class="hs-special">(</span><span class="hs-operator">.|.</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.GDI.Types</span><span>  </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">HWND</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">MbHWND</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.Key</span><span>        </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">VKey</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.Message</span><span>    </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">WindowMessage</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span>        </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">UINT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">BOOL</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">maybePtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Exception.Unsupported</span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">unsupportedVal</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">upgradeWindowsOS</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Info.Version</span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">is7OrLater</span><span> </span><span class="hs-special">)</span><span class="hs-cpp">


#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-26"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">FsModifiers</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">FsModifier</span><span class="hs-special">]</span><span>
</span><span id="line-27"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">FsModifier</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">UINT</span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span class="hs-identifier">mOD_ALT</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FsModifier</span><span>
</span><span id="line-30"></span><span class="hs-identifier">mOD_ALT</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1</span><span>
</span><span id="line-31"></span><span class="hs-identifier">mOD_CONTROL</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FsModifier</span><span>
</span><span id="line-32"></span><span class="hs-identifier">mOD_CONTROL</span><span>   </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2</span><span>
</span><span id="line-33"></span><span class="hs-identifier">mOD_SHIFT</span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FsModifier</span><span>
</span><span id="line-34"></span><span class="hs-identifier">mOD_SHIFT</span><span>     </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">4</span><span>
</span><span id="line-35"></span><span class="hs-identifier">mOD_WIN</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FsModifier</span><span>
</span><span id="line-36"></span><span class="hs-identifier">mOD_WIN</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8</span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="hs-pragma">{-# LINE 35 &quot;libraries\\Win32\\Graphics\\Win32\\Window\\HotKey.hsc&quot; #-}</span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span class="hs-comment">-- | This parameter requires to use Windows 7 or later.</span><span>
</span><span id="line-37"></span><span class="hs-identifier">mOD_NOREPEAT</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FsModifier</span><span>
</span><span id="line-38"></span><span class="hs-identifier">mOD_NOREPEAT</span><span>
</span><span id="line-39"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">unsupportedVal</span><span> </span><span class="hs-string">&quot;MOD_NOREPEAT&quot;</span><span>
</span><span id="line-40"></span><span>      </span><span class="hs-identifier">is7OrLater</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">upgradeWindowsOS</span><span> </span><span class="hs-string">&quot;Windows 7&quot;</span><span class="hs-special">)</span><span> </span><span class="hs-number">0x4000</span><span>
</span><span id="line-41"></span><span class="hs-comment">{-
 , mOD_NOREPEAT = MOD_NOREPEAT
-}</span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span class="hs-identifier">wM_HOTKEY</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowMessage</span><span>
</span><span id="line-46"></span><span class="hs-identifier">wM_HOTKEY</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">786</span><span>
</span><span id="line-47"></span><span class="hs-pragma">{-# LINE 47 &quot;libraries\\Win32\\Graphics\\Win32\\Window\\HotKey.hsc&quot; #-}</span><span>
</span><span id="line-47"></span><span>
</span><span id="line-48"></span><span class="hs-identifier">joinModifiers</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FsModifiers</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">FsModifier</span><span>
</span><span id="line-49"></span><span class="hs-identifier">joinModifiers</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">foldr</span><span> </span><span class="hs-special">(</span><span class="hs-operator">.|.</span><span class="hs-special">)</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-50"></span><span>
</span><span id="line-51"></span><span class="hs-identifier">registerHotKey</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MbHWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">FsModifier</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">VKey</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-52"></span><span class="hs-identifier">registerHotKey</span><span> </span><span class="hs-identifier">mb_wnd</span><span> </span><span class="hs-identifier">kid</span><span> </span><span class="hs-identifier">md</span><span> </span><span class="hs-identifier">vkey</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-53"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">unwords</span><span> </span><span class="hs-special">[</span><span class="hs-string">&quot;RegisterHotKey&quot;</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">show</span><span> </span><span class="hs-identifier">mb_wnd</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">show</span><span> </span><span class="hs-identifier">kid</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">show</span><span> </span><span class="hs-identifier">md</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">show</span><span> </span><span class="hs-identifier">vkey</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span>    </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_RegisterHotKey</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_wnd</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">kid</span><span> </span><span class="hs-identifier">md</span><span> </span><span class="hs-identifier">vkey</span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h RegisterHotKey&quot;</span><span>
</span><span id="line-57"></span><span>  </span><span class="hs-identifier">c_RegisterHotKey</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">VKey</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-58"></span><span>
</span><span id="line-59"></span><span class="hs-identifier">unregisterHotKey</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MbHWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-60"></span><span class="hs-identifier">unregisterHotKey</span><span> </span><span class="hs-identifier">mb_wnd</span><span> </span><span class="hs-identifier">kid</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-61"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">unwords</span><span> </span><span class="hs-special">[</span><span class="hs-string">&quot;UnregisterHotKey&quot;</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">show</span><span> </span><span class="hs-identifier">mb_wnd</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">show</span><span> </span><span class="hs-identifier">kid</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-62"></span><span>    </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_UnregisterHotKey</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybePtr</span><span> </span><span class="hs-identifier">mb_wnd</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">kid</span><span>
</span><span id="line-63"></span><span>
</span><span id="line-64"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h UnregisterHotKey&quot;</span><span>
</span><span id="line-65"></span><span>  </span><span class="hs-identifier">c_UnregisterHotKey</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-66"></span></pre></body></html>